<template>
  <div>
    <div class="my-body">
      <div class="ipt_a">
        <div style="float: left; line-height: 30px" class="tab_font-size">
          授权方：
        </div>
        <el-input
          v-model="input"
          placeholder="请输入内容"
          style="width: 150px; height: 50px; float: left"
        ></el-input>
      </div>
      <div class="ipt_a">
        <div style="float: left; line-height: 30px" class="tab_font-size">
          经销商：
        </div>
        <el-input
          v-model="input"
          placeholder="请输入内容"
          style="width: 150px; height: 50px; float: left"
        ></el-input>
      </div>
      <div class="ipt_a">
        <div style="float: left; line-height: 30px" class="tab_font-size">
          终止日期：
        </div>
        <div class="block">
          <el-date-picker
            v-model="value1"
            type="date"
            placeholder="选择日期"
            style="width: 150px"
          >
          </el-date-picker>
        </div>
      </div>
      <div class="ipt_a">
        <div style="float: left; line-height: 30px" class="tab_font-size">
          医院地区：
        </div>
        <el-input
          v-model="input"
          placeholder="请输入内容"
          style="width: 150px; height: 50px; float: left"
        ></el-input>
      </div>

      <div>
        <div class="ipt_a">
          <div style="float: left; line-height: 30px">授权状态：</div>
          <el-select
            v-model="value"
            placeholder="请选择授权状态"
            style="width: 130px"
          >
            <el-option label="全部" value="beijing"></el-option>
            <el-option label="初审中" value="shanghai"></el-option>
            <el-option label="复审中" value="beijing"></el-option>
            <el-option label="终审中" value="shanghai"></el-option>
            <el-option label="复核中" value="beijing"></el-option>
            <el-option label="申请驳回" value="shanghai"></el-option>
            <el-option label="授权驳回" value="shanghai"></el-option>
          </el-select>
        </div>

        <el-button type="primary" plain>查询</el-button>
        <el-button>清空</el-button>

        <div style="margin-top: 30px">
          <!-- <div>
					<el-button type="primary" @click="area = true">申请</el-button>
					<el-button type="primary">变更</el-button>
					<el-button type="warning">删除</el-button>
					<el-button type="warning">作废</el-button>
				</div> -->
          <el-dialog
            title="申请"
            :visible.sync="area"
            width="50%"
            :before-close="handleClose"
          >
            <div style="width: 100%">
              <el-form ref="form" :model="form" label-width="150px">
                <el-form-item label="授权申请编号">
                  <el-input v-model="form.name" style="width: 200px"></el-input>
                  <el-button type="primary">刷新</el-button>
                </el-form-item>
                <el-form-item label="申请时间">
                  <el-date-picker
                    v-model="value1"
                    type="datetime"
                    placeholder="选择日期时间"
                  >
                  </el-date-picker>
                </el-form-item>
                <el-form-item label="授权起始年月">
                  <el-date-picker
                    v-model="value2"
                    type="date"
                    placeholder="选择日期"
                  >
                  </el-date-picker>
                </el-form-item>
                <el-form-item label="授权终止年月">
                  <el-date-picker
                    v-model="value3"
                    type="date"
                    placeholder="选择日期"
                  >
                  </el-date-picker>
                </el-form-item>
                <el-form-item label="授权年限">
                  <el-select v-model="form.region" placeholder="请选择授权年限">
                    <el-option label="1年" value="shanghai"></el-option>
                    <el-option label="2年" value="beijing"></el-option>
                    <el-option label="3年" value="beijing"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="经销商">
                  <el-input v-model="form.name" style="width: 50px"></el-input>

                  <el-select
                    v-model="form.region"
                    placeholder="请选择活动区域"
                    style="width: 200px"
                  >
                    <el-option label="区域一" value="shanghai"></el-option>
                    <el-option label="区域二" value="beijing"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="授权方">
                  <el-input v-model="form.name" style="width: 50px"></el-input>

                  <el-select
                    v-model="form.region"
                    placeholder="请选择活动区域"
                    style="width: 200px"
                  >
                    <el-option label="区域一" value="shanghai"></el-option>
                    <el-option label="区域二" value="beijing"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="配送方">
                  <el-input v-model="form.name" style="width: 50px"></el-input>

                  <el-select
                    v-model="form.region"
                    placeholder="请选择活动区域"
                    style="width: 200px"
                  >
                    <el-option label="区域一" value="shanghai"></el-option>
                    <el-option label="区域二" value="beijing"></el-option>
                  </el-select>
                </el-form-item>

                <el-form-item>
                  <el-checkbox-group v-model="form.type">
                    <el-checkbox
                      label="经销商,授权方,配送方三方统一"
                      name="type"
                    ></el-checkbox>
                  </el-checkbox-group>
                </el-form-item>

                <el-form-item label="">
                  <el-radio-group v-model="radio">
                    <el-radio label="授权医院"></el-radio>
                    <el-radio label="授权地址"></el-radio>
                  </el-radio-group>
                </el-form-item>
                <el-form-item label="授权医院" v-if="radio == '授权医院'">
                  <el-input v-model="form.name" style="width: 50px"></el-input>

                  <el-select
                    v-model="form.region"
                    placeholder="请选择活动区域"
                    style="width: 200px"
                  >
                    <el-option label="区域一" value="shanghai"></el-option>
                    <el-option label="区域二" value="beijing"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="授权地区" v-if="radio == '授权地址'">
                  <el-input v-model="form.name" style="width: 50px"></el-input>

                  <el-select
                    v-model="form.region"
                    placeholder="请选择活动区域"
                    style="width: 200px"
                  >
                    <el-option label="区域一" value="shanghai"></el-option>
                    <el-option label="区域二" value="beijing"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="产品系列">
                  <el-select
                    v-model="form.region"
                    placeholder="请选择活动区域"
                    style="width: 200px"
                  >
                    <el-option label="区域一" value="shanghai"></el-option>
                    <el-option label="区域二" value="beijing"></el-option>
                  </el-select>
                  <el-checkbox
                    :indeterminate="isIndeterminate"
                    v-model="checkAll"
                    @change="handleCheckAllChange"
                    >全选</el-checkbox
                  >
                </el-form-item>
                <el-form-item label="产品类型">
                  <div style="margin: 15px 0"></div>
                  <el-checkbox-group
                    v-model="checkedCities"
                    @change="handleCheckedCitiesChange"
                  >
                    <el-checkbox
                      v-for="city in cities"
                      :label="city"
                      :key="city"
                      >{{ city }}</el-checkbox
                    >
                  </el-checkbox-group>
                </el-form-item>
                <el-form-item label="授权原因">
                  <el-select
                    v-model="form.region"
                    placeholder="请选择活动区域"
                    style="width: 200px"
                  >
                    <el-option label="入院" value="shanghai"></el-option>
                    <el-option label="招投标" value="beijing"></el-option>
                    <el-option label="其他" value="beijing"></el-option>
                  </el-select>
                  合同商业采购指标(实时段内际付款)：<el-input
                    style="width: 50px; height: 40px"
                    placeholder="0"
                  ></el-input
                  >套 普实先心商采指标
                </el-form-item>
                <el-form-item label="备注">
                  <el-input type="textarea" v-model="form.desc"></el-input>
                </el-form-item>
                <el-form-item>
                  <el-button type="primary" @click="onSubmit">申请</el-button>
                  <el-button>取消</el-button>
                </el-form-item>
              </el-form>
            </div>
          </el-dialog>
          <el-dialog
            title="审批"
            :visible.sync="shenpisa"
            width="30%"
            :before-close="handleClose"
          >
          <el-form ref="form" :model="form" label-width="150px">
                <el-form-item label="是否通过">
                  <el-select v-model="shenhe.status" placeholder="是否通过">
                    <el-option label="通过" value="1">通过</el-option>
                    <el-option label="驳回" value="0">驳回</el-option>
                   
                  </el-select>
                 
                </el-form-item>
                <el-form-item label="备注">
                  <el-input v-model="shenhe.remark" style="width: 200px"></el-input>
                 
                </el-form-item>
              </el-form>
              <el-button type="primary" @click="shenhesfbh">审核</el-button>
              <el-button @click="handleClose">取消</el-button>
        </el-dialog>
          <template>
            <el-table
              :data="tableData"
              border
             :header-cell-style="{background:'#f5f7fa',color:'#606266'}"
              style="width: 100%; margin-top: 30px"
              ref="singleTable"
              highlight-current-row
              @current-change="handleCuChange"
              height="400"
            >
              <el-table-column
                fixed
                prop="bianhao"
                label="授权证书编号"
                width="150"
              >
              </el-table-column>
              <el-table-column
                prop="apply_type_txt"
                label="申请类型"
                width="120"
              >
              </el-table-column>
              <el-table-column prop="create_time" label="申请时间" width="120">
              </el-table-column>
              <el-table-column
                prop="sq_start_date"
                label="授权起始日期"
                width="120"
              >
              </el-table-column>
              <el-table-column
                prop="sq_end_date"
                label="授权终止日期"
                width="120"
              >
              </el-table-column>
              <el-table-column
                prop="product_names"
                label="授权产品"
                width="200"
              >
              </el-table-column>
              <el-table-column prop="is_operation" label="审核" width="200">
                <template slot-scope="scope">
                  <!-- <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button> -->
                  <el-button
                    v-if="scope.row.is_operation == 1"
                    size="mini"
                    @click="handleEdit(scope.$index, scope.row)"
                    >审核</el-button
                  >
                  <div v-else></div>
                </template>
              </el-table-column>

              <el-table-column prop="status_txt" label="授权状态" width="200">
                <!-- <el-button>复核中</el-button> -->
              </el-table-column>
              <el-table-column
                prop="hospital_area_name"
                label="医院地区"
                width="200"
              >
              </el-table-column>
              <el-table-column prop="sqf_name" label="授权方" width="200">
              </el-table-column>
              <el-table-column prop="jxs_name" label="经销商" width="200">
              </el-table-column>
              <el-table-column prop="psf_name" label="配送方" width="200">
              </el-table-column>
              <el-table-column prop="reson_txt" label="授权原因" width="200">
              </el-table-column>
              <el-table-column prop="peisonf" label="其他授权原因" width="200">
              </el-table-column>
              <el-table-column
                prop="sc_target_num"
                label="采购指标"
                width="200"
              >
              </el-table-column>

              <el-table-column label="授权证书" width="100">
                <!-- <template slot-scope="scope">
                 
                  <el-button
                    size="mini"
                    @click="handleEdit(scope.$index, scope.row)"
                    >审核日志</el-button
                  >
                </template> -->
              </el-table-column>
              <!-- <el-table-column prop="peisonf" label="授权证书" width="200">
              </el-table-column> -->
              <el-table-column prop="remark" label="备注" width="200">
              </el-table-column>
              <el-table-column prop="peisonf" label="是否继承" width="200">
              </el-table-column>
              <el-table-column
                prop="peisonf"
                label="是否继承进货额"
                width="200"
              >
              </el-table-column>
              <el-table-column prop="peisonf" label="继承积分" width="200">
              </el-table-column>
              <el-table-column prop="add_admin_name" label="添加用户" width="200">
              </el-table-column>
            </el-table>
          </template>
          <el-pagination
            background
            :current-page="page"
            :page-sizes="[100, 200, 300, 400]"
            :page-size="limit"
            layout="->, total, sizes, prev, pager, next, jumper"
            :total="total"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
          />
        </div>
      </div>
    </div>
    <div>
      <div class="my-body_left">
        <div>授权方资质(上海广慷医疗器械合伙企业(有限合</div>
        <!-- <div style="margin-top: 20px;">
						<el-button type="primary" @click="tablisty = true">上传资质</el-button>
						<el-button type="warning">删除资质</el-button>
					</div> -->
        <template>
          <el-table
            :data="sqflist"
            border
           :header-cell-style="{background:'#f5f7fa',color:'#606266'}"
            style="width: 100%; margin-top: 30px"
          >
            <el-table-column prop="file_name" label="资料名称">
              <!-- <el-button
                size="mini"
                @click="handleEdit(scope.$index, scope.row)"
                >图片</el-button
              > -->
            </el-table-column>
            <el-table-column prop="file_type_txt" label="资料类型">
            </el-table-column>
          </el-table>
        </template>
      </div>
      <el-dialog
        title="添加资质备案文件(企业资质)"
        :visible.sync="tablisty"
        width="30%"
        :before-close="handleClose"
      >
        <el-form ref="form" :model="form" label-width="150px">
          <!-- <el-form-item label="文件路径">
							<el-input v-model="form.name" style="width:200px;"></el-input>
							<el-button type="primary">刷新</el-button>
						</el-form-item>
						 -->

          <el-form-item label="产品系列">
            <el-input v-model="form.name" style="width: 200px"></el-input>
            <el-checkbox
              :indeterminate="isIndeterminate"
              v-model="checkAll"
              @change="handleCheckAllChange"
              >重命名</el-checkbox
            >
          </el-form-item>
          <el-form-item label="文件类型">
            <el-select v-model="form.region" placeholder="请选择活动区域">
              <el-option label="公司营业执照扫描件" value="3"></el-option>
              <el-option label="公司经营许可证扫描件" value="2"></el-option>
              <el-option
                label="公司二类医疗器械许可证扫描件"
                value="1"
              ></el-option>
            </el-select>
          </el-form-item>

          <el-form-item>
            <el-button type="primary" @click="onSubmit">申请</el-button>
            <el-button>取消</el-button>
          </el-form-item>
        </el-form>
      </el-dialog>
      <div class="my-body_left">
        <div>经销商资质(上海广慷医疗器械合伙企业(有限合</div>
        <!-- <div style="margin-top: 20px;">
						<el-button type="primary" @click="tablistya = true">上传资质</el-button>
						<el-button type="warning">删除资质</el-button>
					</div> -->
        <template>
          <el-table
            :data="jxslist"
            border
           :header-cell-style="{background:'#f5f7fa',color:'#606266'}"
            style="width: 100%; margin-top: 30px"
          >
            <el-table-column prop="file_name" label="资料名称">
              <!-- <el-button
                size="mini"
                @click="handleEdit(scope.$index, scope.row)"
                >图片</el-button
              > -->
            </el-table-column>
            <el-table-column prop="file_type_txt" label="资料类型">
            </el-table-column>
          </el-table>
        </template>
      </div>
      <el-dialog
        title="添加资质备案文件(企业资质)"
        :visible.sync="tablistya"
        width="30%"
        :before-close="handleClose"
      >
        <el-form ref="form" :model="form" label-width="150px">
          <el-form-item label="文件路径">
            <el-input v-model="form.name" style="width: 200px"></el-input>
            <el-button type="primary">刷新</el-button>
          </el-form-item>

          <el-form-item label="产品系列">
            <el-input v-model="form.name" style="width: 200px"></el-input>
            <el-checkbox
              :indeterminate="isIndeterminate"
              v-model="checkAll"
              @change="handleCheckAllChange"
              >重命名</el-checkbox
            >
          </el-form-item>
          <el-form-item label="文件类型">
            <el-select v-model="form.region" placeholder="请选择活动区域">
              <el-option label="公司营业执照扫描件" value="3"></el-option>
              <el-option label="公司经营许可证扫描件" value="2"></el-option>
              <el-option
                label="公司二类医疗器械许可证扫描件"
                value="1"
              ></el-option>
              <el-option label="进货关联企业说明" value="4"></el-option>
            </el-select>
          </el-form-item>

          <el-form-item>
            <el-button type="primary" @click="onSubmit">申请</el-button>
            <el-button>取消</el-button>
          </el-form-item>
        </el-form>
      </el-dialog>
      <div class="my-body_left">
        <div>配送方资质(上海广慷医疗器械合伙企业(有限合</div>
        <!-- <div style="margin-top: 20px;">
						<el-button type="primary"  @click="tablistyb = true">上传资质</el-button>
						<el-button type="warning">删除资质</el-button>
					</div> -->
        <template>
          <el-table
            :data="psflist"
            border
           :header-cell-style="{background:'#f5f7fa',color:'#606266'}"
            style="width: 100%; margin-top: 30px"
          >
            <el-table-column prop="file_name" label="资料名称">
              <!-- <el-button
                size="mini"
                @click="handleEdit(scope.$index, scope.row)"
                >图片</el-button
              > -->
            </el-table-column>
            <el-table-column prop="file_type_txt" label="资料类型">
            </el-table-column>
          </el-table>
        </template>
      </div>
      <el-dialog
        title="添加资质备案文件(企业资质)"
        :visible.sync="tablistyb"
        width="30%"
        :before-close="handleClose"
      >
        <el-form ref="form" :model="form" label-width="150px">
          <el-form-item label="文件路径">
            <el-input v-model="form.name" style="width: 200px"></el-input>
            <el-button type="primary">刷新</el-button>
          </el-form-item>

          <el-form-item label="产品系列">
            <el-input v-model="form.name" style="width: 200px"></el-input>
            <el-checkbox
              :indeterminate="isIndeterminate"
              v-model="checkAll"
              @change="handleCheckAllChange"
              >重命名</el-checkbox
            >
          </el-form-item>
          <el-form-item label="文件类型">
            <el-select v-model="form.region" placeholder="请选择活动区域">
              <el-option label="公司营业执照扫描件" value="3"></el-option>
              <el-option label="公司经营许可证扫描件" value="2"></el-option>
              <el-option
                label="公司二类医疗器械许可证扫描件"
                value="1"
              ></el-option>
              <el-option label="进货关联企业说明" value="4"></el-option>
            </el-select>
          </el-form-item>

          <el-form-item>
            <el-button type="primary" @click="onSubmit">申请</el-button>
            <el-button>取消</el-button>
          </el-form-item>
        </el-form>
      </el-dialog>
    </div>
  </div>
</template>

<script>
import { getData, postData } from "@/utils/request.js";
export default {
  data() {
    return {
      area: false,
      tablisty: false,
      tablistya: false,
      tablistyb: false,
      key: 1, // 为了能每次切换权限的时候重新初始化指令
      options: [
        {
          value: "1",
          label: "全部",
        },
        {
          value: "2",
          label: "一般订单",
        },
        {
          value: "3",
          label: "积分订单",
        },
        {
          value: "3",
          label: "样品订单",
        },
        {
          value: "3",
          label: "换货订单",
        },
      ],
      value1: "",
      value2: "",
      value3: "",
      form: {
        name: "",
        region: "",
        date1: "",
        date2: "",
        delivery: false,
        type: [],
        resource: "",
        desc: "",
      },
      radio: "授权医院",
      value: "",
      tableData: [
        {
          bianhao: "PS074107742412L",
          senddate: "2024-05-02",
          enddate: "2024-12-31",
          name: "左心耳",
          province: "完成授权",
          city: "普陀区",
          address: "苏州市中心医院",
          shouqfang: "鹰潭市方园医药有限公司",
          jingxiaos: "鹰潭市方园医药有限公司",
          peisonf: "鹰潭市方园医药有限公司",
          shouqyy: "入院",
          shangcaizhibiao: 3,
        },
      ],
      checkAll: false,
      checkedCities: [],
      cities: [
        "房间隔缺损",
        "室间隔缺损",
        "介入输送装置",
        "动脉导管未闭",
        "抓捕器",
      ],
      isIndeterminate: true,
      total: "",
      radio: "1",
      bgform: "",
      currentRow: "",
      jxslist: [],
      psflist: [],
      sqflist: [],
      limit: "100",
      page: "1",
      shenpisa:false,
      shenhe:{
        id:"",
        remark:"",
        status:"",
      },
      input:"",
      currentPage:"",
      pageSize:"",
    };
  },
  created() {
    this.shouquanlist();
  },
  methods: {
    onSubmit(){
      
    },
    handleClose(){
      this.shenpisa = false
    },
    handleEdit(index, row) {
      console.log(index, row);
      this.shenhe.id = row.id
      this.shenpisa = true
      
    },
    shenhesfbh(){
      var data = {
        id: this.shenhe.id,
        remark: this.shenhe.remark,
        status: this.shenhe.status,
        token: localStorage.getItem("token"),
      };
      console.log(data)
     
       postData("company.empower/handleEmpower", data).then((res) => {
        console.log(res)
        this.shenpisa = false
        this.shouquanlist()
      });
    },
    btnshenhe() {},
    handleSizeChange(val) {
      this.limit = val;
      this.shouquanlist();
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      this.page = val;
      this.shouquanlist();
      console.log(`当前页: ${val}`);
    },
    handleCuChange(val) {
      this.radio = val.sq_type;

      this.bgform = val;
      this.currentRow = val;
      this.jxs();
    },
    jxs() {
      var data = {
        jxs_id: this.bgform.jxs_id,
        psf_id: this.bgform.psf_id,
        sqf_id: this.bgform.sqf_id,
        token: localStorage.getItem("token"),
      };
      postData("company.empower/getcompanyFileList", data).then((res) => {
        console.log(res.data);
        this.jxslist = res.data.jxs;
        this.psflist = res.data.psf;
        this.sqflist = res.data.sqf;
      });
    },
    shouquanlist() {
      var data = {
        limit: this.limit,
        page: this.page,
        token: localStorage.getItem("token"),
      };
      postData("company.empower/spList", data).then((res) => {
        this.tableData = res.data.data;
        this.total = res.data.total;
        this.setCurrent();
      });
    },
    setCurrent() {
      this.$refs.singleTable.setCurrentRow(this.tableData[0]);
    },
    handleClick(row) {
      console.log(row);
    },
    handleCheckAllChange(val) {
      const cityOptions = ["上海", "北京", "广州", "深圳"];
      console.log(val);
      this.checkedCities = val ? cityOptions : [];

      this.isIndeterminate = false;
    },
    handleCheckedCitiesChange(value) {
      let checkedCount = value.length;
      this.checkAll = checkedCount === this.cities.length;
      this.isIndeterminate =
        checkedCount > 0 && checkedCount < this.cities.length;
    },
  },
};
</script>

<style lang="scss" scoped>
.ipt_a {
  width: 240px;
  height: 50px;
  float: left;
}

.ipt_b {
  width: 450px;
  height: 50px;
  float: left;
}
</style>